package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;

import com.example.myapplication.adapter.FoodInfo;

import java.util.ArrayList;
import java.util.List;

public class BaseAdapterActivity extends AppCompatActivity {
    private ListView listview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base_adapter);
        initView();

    }

    private void initView() {
        listview = findViewById(R.id.lv_base);//找到对应的组件

        List<FoodInfo> data = new ArrayList<FoodInfo>();
        data.add(new FoodInfo(R.drawable.widget01,"title--1","content--1"));
        data.add(new FoodInfo(R.drawable.widget02,"title--2","content--2"));
        data.add(new FoodInfo(R.drawable.widget03,"title--3","content--3"));
        data.add(new FoodInfo(R.drawable.widget04,"title--4","content--4"));
        data.add(new FoodInfo(R.drawable.widget05,"title--5","content--5"));
        data.add(new FoodInfo(R.drawable.widget06,"title--6","content--6"));
        data.add(new FoodInfo(R.drawable.widget07,"title--7","content--7"));
        data.add(new FoodInfo(R.drawable.widget08,"title--8","content--8"));
        data.add(new FoodInfo(R.drawable.widget09,"title--9","content--9"));

        FoodAdapter adapter = new FoodAdapter(this, R.layout.food_item,data);

        listview.setAdapter(adapter);
    }
}